namespace QMVnSoft.ReportForms
{
    using QMVnSoft;
    using QMVnSoft.Controls;
    using QMVnSoft.DAL;
    using System;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Windows.Forms;

    public class FormKCD00Viewer : FormReportViewer
    {
        private IContainer components;
        private LabelControl lblBac_Tk;
        private LabelControl lblNgay_Ct1;
        private LabelControl lblNgay_Ct2;
        private LabelControl lblTk;
        private TextNumeric txtBac_Tk;
        private TextDate txtNgay_Ct1;
        private TextDate txtNgay_Ct2;
        private TextControl txtTen_Tk;
        private TextSearch txtTk;

        public FormKCD00Viewer()
        {
            this.InitializeComponent();
            this.txtNgay_Ct1.Value = AppInstance.StartWorkingDate;
            this.txtNgay_Ct2.Value = AppInstance.EndWorkingDate;
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormKCD00Viewer));
            this.txtNgay_Ct2 = new QMVnSoft.Controls.TextDate();
            this.lblNgay_Ct2 = new QMVnSoft.Controls.LabelControl();
            this.txtNgay_Ct1 = new QMVnSoft.Controls.TextDate();
            this.lblNgay_Ct1 = new QMVnSoft.Controls.LabelControl();
            this.txtTen_Tk = new QMVnSoft.Controls.TextControl();
            this.txtTk = new QMVnSoft.Controls.TextSearch();
            this.lblTk = new QMVnSoft.Controls.LabelControl();
            this.txtBac_Tk = new QMVnSoft.Controls.TextNumeric();
            this.lblBac_Tk = new QMVnSoft.Controls.LabelControl();
            this.rptContainer.Panel1.SuspendLayout();
            this.rptContainer.SuspendLayout();
            this.SuspendLayout();
            // 
            // rptContainer
            // 
            // 
            // rptContainer.Panel1
            // 
            this.rptContainer.Panel1.Controls.Add(this.txtBac_Tk);
            this.rptContainer.Panel1.Controls.Add(this.txtNgay_Ct2);
            this.rptContainer.Panel1.Controls.Add(this.lblNgay_Ct2);
            this.rptContainer.Panel1.Controls.Add(this.txtNgay_Ct1);
            this.rptContainer.Panel1.Controls.Add(this.lblNgay_Ct1);
            this.rptContainer.Panel1.Controls.Add(this.txtTen_Tk);
            this.rptContainer.Panel1.Controls.Add(this.txtTk);
            this.rptContainer.Panel1.Controls.Add(this.lblBac_Tk);
            this.rptContainer.Panel1.Controls.Add(this.lblTk);
            this.rptContainer.SplitterDistance = 67;
            // 
            // txtNgay_Ct2
            // 
            this.txtNgay_Ct2.DateTimeFormat  = QMVnSoft.Controls.TextDate.DateTimeFormatType.Date;
            this.txtNgay_Ct2.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtNgay_Ct2.InsertKeyMode = System.Windows.Forms.InsertKeyMode.Overwrite;
            this.txtNgay_Ct2.Location = new System.Drawing.Point(316, 45);
            this.txtNgay_Ct2.Mask = "00/00/0000";
            this.txtNgay_Ct2.Name = "txtNgay_Ct2";
            this.txtNgay_Ct2.OldValue = null;
            this.txtNgay_Ct2.Size = new System.Drawing.Size(100, 20);
            this.txtNgay_Ct2.TabIndex = 7;
            this.txtNgay_Ct2.Value = ((object)(resources.GetObject("txtNgay_Ct2.Value")));
            // 
            // lblNgay_Ct2
            // 
            this.lblNgay_Ct2.AutoSize = true;
            this.lblNgay_Ct2.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblNgay_Ct2.Location = new System.Drawing.Point(256, 48);
            this.lblNgay_Ct2.Name = "lblNgay_Ct2";
            this.lblNgay_Ct2.Size = new System.Drawing.Size(54, 14);
            this.lblNgay_Ct2.TabIndex = 116;
            this.lblNgay_Ct2.Text = "Đến ngày";
            // 
            // txtNgay_Ct1
            // 
            this.txtNgay_Ct1.DateTimeFormat  = QMVnSoft.Controls.TextDate.DateTimeFormatType.Date;
            this.txtNgay_Ct1.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtNgay_Ct1.InsertKeyMode = System.Windows.Forms.InsertKeyMode.Overwrite;
            this.txtNgay_Ct1.Location = new System.Drawing.Point(108, 45);
            this.txtNgay_Ct1.Mask = "00/00/0000";
            this.txtNgay_Ct1.Name = "txtNgay_Ct1";
            this.txtNgay_Ct1.OldValue = null;
            this.txtNgay_Ct1.Size = new System.Drawing.Size(100, 20);
            this.txtNgay_Ct1.TabIndex = 6;
            this.txtNgay_Ct1.Value = ((object)(resources.GetObject("txtNgay_Ct1.Value")));
            // 
            // lblNgay_Ct1
            // 
            this.lblNgay_Ct1.AutoSize = true;
            this.lblNgay_Ct1.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblNgay_Ct1.Location = new System.Drawing.Point(12, 48);
            this.lblNgay_Ct1.Name = "lblNgay_Ct1";
            this.lblNgay_Ct1.Size = new System.Drawing.Size(47, 14);
            this.lblNgay_Ct1.TabIndex = 117;
            this.lblNgay_Ct1.Text = "Từ ngày";
            // 
            // txtTen_Tk
            // 
            this.txtTen_Tk.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txtTen_Tk.BackColor = System.Drawing.SystemColors.Control;
            this.txtTen_Tk.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.txtTen_Tk.CheckTextSearched = false;
            this.txtTen_Tk.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtTen_Tk.Enabled = false;
            this.txtTen_Tk.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTen_Tk.ForeColor = System.Drawing.Color.Blue;
            this.txtTen_Tk.Location = new System.Drawing.Point(214, 6);
            this.txtTen_Tk.Name = "txtTen_Tk";
            this.txtTen_Tk.OldValue = null;
            this.txtTen_Tk.Size = new System.Drawing.Size(458, 13);
            this.txtTen_Tk.TabIndex = 110;
            this.txtTen_Tk.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.None;
            this.txtTen_Tk.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.txtTen_Tk.Value = ((object)(resources.GetObject("txtTen_Tk.Value")));
            // 
            // txtTk
            // 
            this.txtTk.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtTk.CheckTextSearched = false;
            this.txtTk.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtTk.EmptyIsValid = true;
            this.txtTk.FieldDisplay = "Ten_Tk";
            this.txtTk.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTk.FoundIsValid = true;
            this.txtTk.Location = new System.Drawing.Point(108, 3);
            this.txtTk.MaxLength = 32;
            this.txtTk.Name = "txtTk";
            this.txtTk.OldValue = null;
            this.txtTk.Size = new System.Drawing.Size(100, 20);
            this.txtTk.TabIndex = 0;
            this.txtTk.TableName = "DMTK";
            this.txtTk.TextDisplay = this.txtTen_Tk;
            this.txtTk.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.ItemCode;
            this.txtTk.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.All;
            this.txtTk.Value = ((object)(resources.GetObject("txtTk.Value")));
            // 
            // lblTk
            // 
            this.lblTk.AutoSize = true;
            this.lblTk.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblTk.Location = new System.Drawing.Point(12, 6);
            this.lblTk.Name = "lblTk";
            this.lblTk.Size = new System.Drawing.Size(53, 14);
            this.lblTk.TabIndex = 106;
            this.lblTk.Text = "Tài khoản";
            // 
            // txtBac_Tk
            // 
            this.txtBac_Tk.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtBac_Tk.Location = new System.Drawing.Point(108, 24);
            this.txtBac_Tk.Name = "txtBac_Tk";
            this.txtBac_Tk.NumericPrecision = 2;
            this.txtBac_Tk.NumericScaleOnFocus = 0;
            this.txtBac_Tk.NumericScaleOnLostFocus = 0;
            this.txtBac_Tk.NumericValue = new decimal(new int[] {
            3,
            0,
            0,
            0});
            this.txtBac_Tk.OldValue = null;
            this.txtBac_Tk.Size = new System.Drawing.Size(22, 20);
            this.txtBac_Tk.TabIndex = 3;
            this.txtBac_Tk.Text = "3";
            this.txtBac_Tk.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            this.txtBac_Tk.UserTextNumericFormat  = QMVnSoft.AppInstance.TextNumericFormat.None;
            this.txtBac_Tk.Value = new decimal(new int[] {
            3,
            0,
            0,
            0});
            // 
            // lblBac_Tk
            // 
            this.lblBac_Tk.AutoSize = true;
            this.lblBac_Tk.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblBac_Tk.Location = new System.Drawing.Point(12, 27);
            this.lblBac_Tk.Name = "lblBac_Tk";
            this.lblBac_Tk.Size = new System.Drawing.Size(72, 14);
            this.lblBac_Tk.TabIndex = 107;
            this.lblBac_Tk.Text = "Bậc tài khoản";
            // 
            // FormKCD00Viewer
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.ClientSize = new System.Drawing.Size(794, 539);
            this.Name = "FormKCD00Viewer";
            this.rptContainer.Panel1.ResumeLayout(false);
            this.rptContainer.Panel1.PerformLayout();
            this.rptContainer.ResumeLayout(false);
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        protected override void OnGenerateColumns()
        {
            if (base.CurrencyIndex == 0)
            {
                object[][] objArray = new object[8][];
                object[] objArray2 = new object[4];
                objArray2[0] = "Tk";
                objArray2[1] = "Tài khoản";
                objArray2[2] = "C";
                objArray[0] = objArray2;
                object[] objArray3 = new object[4];
                objArray3[0] = "Ten_Tk";
                objArray3[1] = "Tên tài khoản";
                objArray3[2] = "C";
                objArray[1] = objArray3;
                objArray[2] = new object[] { "Du_No1", "Dư nợ đầu", "N", AppInstance.TextNumericFormat.LocalAmount };
                objArray[3] = new object[] { "Du_Co1", "Dư có đầu", "N", AppInstance.TextNumericFormat.LocalAmount };
                objArray[4] = new object[] { "Ps_No", "Ps nợ", "N", AppInstance.TextNumericFormat.LocalAmount };
                objArray[5] = new object[] { "Ps_Co", "Ps có", "N", AppInstance.TextNumericFormat.LocalAmount };
                objArray[6] = new object[] { "Du_No2", "Dư nợ cuối", "N", AppInstance.TextNumericFormat.LocalAmount };
                objArray[7] = new object[] { "Du_Co2", "Dư có cuối", "N", AppInstance.TextNumericFormat.LocalAmount };
                base.LocalColNames = objArray;
            }
            else
            {
                object[][] objArray10 = new object[8][];
                object[] objArray11 = new object[4];
                objArray11[0] = "Tk";
                objArray11[1] = "Tài khoản";
                objArray11[2] = "C";
                objArray10[0] = objArray11;
                object[] objArray12 = new object[4];
                objArray12[0] = "Ten_Tk";
                objArray12[1] = "Tên tài khoản";
                objArray12[2] = "C";
                objArray10[1] = objArray12;
                objArray10[2] = new object[] { "Du_No_Nt1", "Dư nợ đầu", "N", AppInstance.TextNumericFormat.ForeignAmount };
                objArray10[3] = new object[] { "Du_Co_Nt1", "Dư có đầu", "N", AppInstance.TextNumericFormat.ForeignAmount };
                objArray10[4] = new object[] { "Ps_No_Nt", "Ps nợ", "N", AppInstance.TextNumericFormat.ForeignAmount };
                objArray10[5] = new object[] { "Ps_Co_Nt", "Ps có", "N", AppInstance.TextNumericFormat.ForeignAmount };
                objArray10[6] = new object[] { "Du_No_Nt2", "Dư nợ cuối", "N", AppInstance.TextNumericFormat.ForeignAmount };
                objArray10[7] = new object[] { "Du_Co_Nt2", "Dư có cuối", "N", AppInstance.TextNumericFormat.ForeignAmount };
                base.ForeignColNames = objArray10;
            }
            base.OnGenerateColumns();
        }

        protected override void OnMakeReport()
        {
            AppInstance.StartWorkingDate = (DateTime) this.txtNgay_Ct1.Value;
            AppInstance.EndWorkingDate = (DateTime) this.txtNgay_Ct2.Value;
            base.LocalTable = new ReportDataAccess().KCT01T_Get(AppInstance.Subsidiaries, this.txtNgay_Ct1.Value, this.txtNgay_Ct2.Value, this.txtTk.Value, this.txtBac_Tk.Value, AppInstance.DefLanguage);
            base.OnMakeReport();
        }

        protected override void OnSendParameters()
        {
            base.StimulReport["Ngay"] = "Từ ngày " + string.Format("{0:dd/MM/yyyy}", this.txtNgay_Ct1.Value) + " đến ngày " + string.Format("{0:dd/MM/yyyy}", this.txtNgay_Ct2.Value);
            if (string.IsNullOrEmpty(this.txtTk.Value.ToString()))
            {
                base.StimulReport["TaiKhoan"] = "";
            }
            else
            {
                base.StimulReport["TaiKhoan"] = string.Concat(new object[] { "Tài khoản: ", this.txtTen_Tk.Value, " (", this.txtTk.Value, ")" });
            }
        }

        protected override void OnShowDetail()
        {
            DataRow row = ((DataRowView) base.DataGridBrowser.CurrentRow.DataBoundItem).Row;
            object obj2 = row["Tk"];
            object obj3 = row["Tk_Dt"];
            if (obj2 != null)
            {
                if (obj3.ToString() == "K")
                {
                    FormKTH01Viewer viewer = new FormKTH01Viewer(this.txtNgay_Ct1.Value, this.txtNgay_Ct2.Value, "", obj2, this.txtBac_Tk.Value, "", "*", "", "", base.CurrencyIndex);
                    viewer.TitleText = "Báo cáo tổng hợp tài khoản";
                    viewer.ReportTitle = "Báo cáo tổng hợp tài khoản";
                    viewer.ReportFile = "KTH01";
                    viewer.Show();
                }
                else
                {
                    FormKTH02CNViewer viewer2 = new FormKTH02CNViewer(this.txtNgay_Ct1.Value, this.txtNgay_Ct2.Value, obj2, "", "", base.CurrencyIndex);
                    viewer2.TitleText = "Báo cáo công nợ";
                    viewer2.ReportTitle = "Báo cáo công nợ";
                    viewer2.ReportFile = "KTH02";
                    viewer2.Show();
                }
            }
        }
    }
}

